package com.hxy.travel.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.hxy.travel.dao.MemberDao;
import com.hxy.travel.service.MemberService;
import com.hxy.travel.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@Service( interfaceClass = MemberService.class)
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberDao memberDao;


    @Override
    public List<Integer> findMemberCountByMonth(List<String> listDate) {
        List<Integer> memberCounts = new ArrayList<>();
        if (listDate !=null && listDate.size() > 0){
            for (String month : listDate) {
                String registerTime = DateUtils.getLastDayOfMonth(month);
                Integer memberCount = memberDao.findMemberCountByMonth(registerTime);
                memberCounts.add(memberCount);
            }

        }
        return memberCounts;
    }
}
